fix: Improve error message for HTTPS on HTTP port#12447
Closed
NIK-TIGER-BILL wants to merge 2 commits intoaio-libs:masterfrom
Closed
fix: Improve error message for HTTPS on HTTP port#12447NIK-TIGER-BILL wants to merge 2 commits intoaio-libs:masterfrom
NIK-TIGER-BILL wants to merge 2 commits intoaio-libs:masterfrom
Conversation
Detect TLS handshake bytes (\x16\x03) at the start of the request and raise a descriptive BadHttpMethod error explaining that the client appears to be trying to connect via HTTPS to an HTTP port. Fixes aio-libs#10142 Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
for more information, see https://pre-commit.ci
Merging this PR will not alter performance
Comparing Footnotes
|
❌ 2 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What do these changes do?
Improved the error message in
HttpRequestParserwhen a client sends TLS handshake bytes (\x16\x03) to an HTTP port. Previously, this produced a genericBad HTTP methoderror which was confusing for users. Now it raises a clearBadHttpMethodexplaining that the client appears to be trying to connect via HTTPS to an HTTP port.Are there changes in behavior for the user?
Yes — the error message for this very common misconfiguration is now self-explanatory. No API changes.
Is it a substantial burden for the maintainers to support this?
No. The change is a single early-exit check in the parser with an accompanying unit test.
Related issue number
Fixes #10142
Checklist
CONTRIBUTORS.txtCHANGES/folder